package ch09;

class _34_RandomEx3 {
	final static int RECORD_NUM = 10;
	final static String TABLE_NAME = "TEST_TABLE";
	final static String[] CODE1 = { "02", "051", "053", "032", "062" };
	final static String[] CODE2 = { "남자", "여자" };
	final static String[] CODE3 = { "10대", "20대", "30대", "40대", "50대" };

	public static void main(String[] args) {
		for (int i = 0; i < RECORD_NUM; i++) {
			System.out.println(" INSERT INTO " + TABLE_NAME + " VALUES ("
					+ " '" + getRandArr(CODE1) + "', '"
					+ getRandArr(CODE2) + "', '" + getRandArr(CODE3) + "', " 
					+ getRand(100, 200) + "); ");
		}
	}

	static String getRandArr(String[] arr) {
		return arr[getRand(arr.length - 1)]; 
	}

	static int getRand(int n) {
		return getRand(0, n);
	}

	static int getRand(int from, int to) {
		return (int) (Math.random() * (Math.abs(to - from) + 1)) + Math.min(from, to);
	}
}
/*
INSERT INTO TEST_TABLE VALUES ( '062', '여자', '50대', 177); 
INSERT INTO TEST_TABLE VALUES ( '02', '남자', '40대', 146); 
INSERT INTO TEST_TABLE VALUES ( '051', '남자', '20대', 147); 
INSERT INTO TEST_TABLE VALUES ( '032', '여자', '50대', 110); 
INSERT INTO TEST_TABLE VALUES ( '051', '여자', '20대', 115); 
INSERT INTO TEST_TABLE VALUES ( '062', '남자', '50대', 124); 
INSERT INTO TEST_TABLE VALUES ( '032', '여자', '50대', 144); 
INSERT INTO TEST_TABLE VALUES ( '032', '여자', '20대', 112); 
INSERT INTO TEST_TABLE VALUES ( '062', '여자', '50대', 197); 
INSERT INTO TEST_TABLE VALUES ( '051', '여자', '20대', 162); 
*/